#include "hexahedron.h"

namespace visualization
{

const size_t Hexahedron::facets[24] = {
	0, 1, 2, 3,
	0, 4, 5, 1,
	1, 5, 6, 2,
	2, 6, 7, 3,
	3, 7, 4, 0,
	7, 6, 5, 4};
const size_t Hexahedron::facet_offsets[6] = { 0, 4, 8, 12, 16, 20 };
const size_t Hexahedron::facet_size[6] = { 4, 4, 4, 4, 4, 4 };

CellType Hexahedron::GetFacet(size_t i, size_t *point_ids)
{
	size_t offset = facet_offsets[i];
	for (size_t j=0; j<facet_size[i]; j++)
		point_ids[j] = facets[offset + j];
	return QUADRANGEL;
}

Point Hexahedron::GetBeryCenter() const
{
	Point ret, *cur = 0;

	for (size_t i=0; i<8; i++)
	{
		cur = server->GetPoint(i);
		ret.x += cur->x;
		ret.y += cur->y;
		ret.z += cur->z;
	}

	ret.x /= 8;
	ret.y /= 8;
	ret.z /= 8;

	return ret;
}

}

